package com.muyu.product.domain.model;

import com.muyu.common.core.web.domain.TreeEntity;
import com.muyu.product.domain.CategoryInfo;
import com.muyu.product.domain.req.CategoryInfoSaveReq;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.util.Date;
import java.util.List;
import java.util.function.Supplier;

/**
 * 品类信息对象 category_info
 *
 * @author DongZeLiang
 * @date 2024-02-27
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class CategoryInfoSaveModel extends TreeEntity {

    private static final long serialVersionUID = 1L;


    /** 品类名称 */
    private String name;

    /** 图片 */
    private String image;

    /** 是否启用 */
    private String start;

    /** 介绍 */
    private String introduction;

    /**
     * 商品属性组关联ID
     */
    private List<Long> attributeGroupIdList;
    /**
     * 商品属性关联ID
     */
    private List<Long> attributeIdList;

    /**
     * 商品品牌组关联ID
     */
    private List<Long> brandIdList;

    /**
     * 添加构造器
     */
    public static CategoryInfoSaveModel saveBuild(CategoryInfoSaveReq categoryInfoSaveReq, Supplier<String> supplier){
        return CategoryInfoSaveModel.builder()
                .name(categoryInfoSaveReq.getName())
                .image(categoryInfoSaveReq.getImage())
                .start(categoryInfoSaveReq.getStart())
                .introduction(categoryInfoSaveReq.getIntroduction())
                .parentId(categoryInfoSaveReq.getParentId())
                .attributeGroupIdList(categoryInfoSaveReq.getAttributeGroupIdList())
                .attributeIdList(categoryInfoSaveReq.getAttributeIdList())
                .brandIdList(categoryInfoSaveReq.getBrandIdList())
                .createBy(supplier.get())
                .createTime(new Date())
                .build();
    }

}
